
/*
 * sndpipe: A UNIX pipes-based audio stream processor toolkit.
 * Copyright (C) 2011  Bradley Worley
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to:
 *
 *   Free Software Foundation, Inc.
 *   51 Franklin Street, Fifth Floor
 *   Boston, MA  02110-1301, USA.
 */

/* ensure once-only inclusion. */
#ifndef __SNDPIPE_HW__
#define __SNDPIPE_HW__

/* define the hardware structure used to capture and output audio data. */
struct hardware {
  /* declare the alsa hardware parameters and handle. */
  snd_pcm_hw_params_t *parms;
  snd_pcm_t *dh;

  /* declare frequently used parameters. */
  int channels;

  /* declare the buffer and its size parameter. */
  int *buf;
  unsigned long buf_size;
};

/* begin function definitions below: */

struct hardware *hw_open_input (unsigned int rate);

struct hardware *hw_open_output (void);

int hw_close (struct hardware *hw);

int hw_write (struct hardware *hw, double **buf, unsigned long frames);

int hw_read (struct hardware *hw, double ***buf, unsigned long frames);

double **hw_buf_alloc (struct hardware *hw, unsigned long *frames);

void hw_buf_free (struct hardware *hw, unsigned long frames, double **buf);

int hw_get_format (void);

#endif /* __SNDPIPE_HW__ */

